require.config({
	paths: {
		echarts: '../../plugins/echat/dist'
	}
});
jQuery(document).ready(function() {
	loadEchartsData();
});	
function loadEchartsData() {
	var mycars=new Array()
	mycars[0]="1000";
	mycars[1]="1000";
	mycars[2]="100";
	mycars[3]="1000";
	require(
		[
			'echarts',
			'echarts/chart/line',
			'echarts/chart/bar',
			'echarts/chart/pie'
		],
		function(ec) {
			// 基于准备好的dom，初始化echarts图表
			var myChart = ec.init(document.getElementById('divOne'));
			var ecConfig = require('echarts/config');
			myChart.on(ecConfig.EVENT.CLICK, "");
			option = {
//				title: {
//					show: true,
//					zlevel: 0,
//					z: 6,
//					text: 'fefef',
//					link: '',
//					target: null,
//					subtext: '',
//					sublink: '',
//					subtarget: null,
//					x: 'left',
//					y: 'top',
//					textAlign:'center' ,
//					backgroundColor: 'rgba(0,0,0,0)',
//					borderColor: '#ccc',
//					borderWidth: 0,
//					padding: 5,
//					itemGap: 5
//				},
				title:{
					text: '年收入与支出预算对比',
					x:'center',
					y:'',
					padding:mycars,//标题内边距，单位px，默认各方向内边距为5，接受数组分别设定上右下左边距
          			itemGap: 100,//主副标题纵向间隔，单位px，默认为10
					textAlign:null,
					subtext:'金额(万元)'
				},
		        grid: { // 控制图的大小，调整下面这些值就可以，
		            x: 10,
		            x2: 100,
		            y2: 50// y2可以控制 X轴跟Zoom控件之间的间隔，避免以为倾斜后造成 label重叠到zoom上
     			},
			    tooltip : {
			        trigger: 'axis'
			    },
			    toolbox: {
			        show : true,
			        y: 'bottom',
			        feature : {
			            mark : {show: true},
			            dataView : {show: true, readOnly: false},
			            magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
			            restore : {show: true},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    legend: {
			        data:['实际收入','实际支出','计划收入','计划支出','','百度','谷歌','必应','其他'],
			        x: 'right',
			        selectedMode: 'single'  ,
			        inactiveColor: '#999' 
			    },
			    xAxis:[
			        {
			            type : 'category',
			            splitLine : {show : false},
			            data : ['2011','2012','2013','2014','2015','2016','2017']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value',
			            position: 'right'
			        }
			    ],
			   calculable : false,
			    series : [
			        {
			            name:'实际收入',
			            type:'bar',
			            tooltip : {trigger: 'item'},
			            stack: '收入',
			            data:[320, 332, 301, 334, 390, 330, 320]
			        },
			        {
			            name:'实际支出',
			            type:'bar',
			            tooltip : {trigger: 'item'},
			            stack: '支出',
			            data:[120, 132, 101, 134, 90, 230, 210]
			        },
			        {
			            name:'计划收入',
			            type:'bar',
			            tooltip : {trigger: 'item'},
			            stack: '收入',
			            data:[220, 182, 191, 234, 290, 330, 310]
			        },
			        {
			            name:'计划支出',
			            type:'bar',
			            tooltip : {trigger: 'item'},
			            stack: '支出',
			            data:[150, 232, 201, 154, 190, 330, 410]
			        },
			        {
			            name:'搜索引擎',
			            type:'line',
			            data:[862, 1018, 964, 1026, 1679, 1600, 1570]
			        },
			        {
			            name:'搜索引擎细分',
			            type:'pie',
			            tooltip : {
			                trigger: 'item',
			                formatter: '{a} <br/>{b} : {c} ({d}%)'
			            },
			            calculable : true,
			            center: [160,120],
			            radius : [0, 50],
			            itemStyle :　{
			                normal : {
			                    labelLine : {
			                        length : 50
			                    }
			                }
			            },
			            data:[
			                {value:1048, name:'百度'},
			                {value:251, name:'谷歌'},
			                {value:147, name:'必应'},
			                {value:102, name:'其他'}
			            ]
			        }
			    ]
			};
			// 为echarts对象加载数据 
			myChart.setOption(option);
		}
	);
	
}
